﻿using UnityEditor;

namespace GMBase.UI
{
    /// <summary>
    /// the CustomEditor of "Window" component
    /// </summary>
    [CustomEditor(typeof(GWindow), true)]
    public class WinEditor:Editor
    {
        public override void OnInspectorGUI()
        {
            EditorGUILayout.BeginVertical();
            {
                //base.OnInspectorGUI();

                //now draw the UI of all properties of Window
                GWindow win = (GWindow)target;

                //Layer Property
                string[] layerStrs = System.Enum.GetNames(typeof(WindowLayer));
                ArrayUtility.RemoveAt(ref layerStrs, layerStrs.Length - 1);
                WindowLayer layer = (WindowLayer)EditorGUILayout.Popup("层级", (int)win.m_Layer, layerStrs);
                if (layer != win.m_Layer )
                {
                    win.m_Layer = layer;
                    EditorUtility.SetDirty(target);
                }
               bool isfull = EditorGUILayout.Toggle("全屏", win.m_IsFullScreen);
               if( isfull != win.m_IsFullScreen )
               {
                   win.m_IsFullScreen = isfull;
                   EditorUtility.SetDirty(target);
               }
                //CloseButtonVisible Property
               //if (win.CloseButtonExist)
               //{
               //    bool closeVisible = EditorGUILayout.Toggle("关闭按钮", win.CloseButtonVisible);
               //    if( closeVisible != win.CloseButtonVisible )
               //    {
               //        win.CloseButtonVisible = closeVisible;
               //        EditorUtility.SetDirty(target);
               //    }

               //}
               //string[] skinStrs = System.Enum.GetNames(typeof(WindowSkin));
               //WindowSkin skin = (WindowSkin)EditorGUILayout.Popup("皮肤", (int)win.skin, skinStrs);
               //if(skin != win.skin)
               //{
               //    win.skin = skin;
               //    EditorUtility.SetDirty(target);
               //    win.UpdateSkin();
               //}
               //if(skin != WindowSkin.None)
               //{
               //    win.title = EditorGUILayout.TextField("标题", win.title);
               //    EditorUtility.SetDirty(target);
               //}


                //win.openSound = EditAudioResIDList.JustDraw(win.openSound, true, "窗口打开时音效:");
                //win.closeSound = EditAudioResIDList.JustDraw(win.closeSound, true, "窗口关闭时音效:");
            }

            EditorGUILayout.EndVertical();
        }
    }
}
